layui.define([ 'form', 'laydate', 'table','skillApi'], function(exports) {
    var form = layui.form;
    var skillApi = layui.skillApi;
    var index = layui.index;
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                 form.on('submit(form)', function(){
                     /**
                      * 获取文件
                      */

                     var isEmpty = Common.fileRequire("#bankCardNumberProveDataList");
                     var certificateScanning = Common.fileRequire("#certificateScanningDataList");

                     if(isEmpty){
                         Common.alert("银行卡材料信息附件必须上传");
                     }else if(certificateScanning){
                          Common.alert("相应的证书扫描件附件必须上传");
                     }else {
                         skillApi.addSkill($('#addForm'), function () {
                             parent.window.dataReload();
                             Common.info("添加成功");
                             Lib.closeFrame();
                         });
                     }
                });
            });

            $("#addButton-PandD").click(function(){
                form.on('submit(form)', function() {
                    /**
                     * 获取文件
                     */

                    var isEmpty = Common.fileRequire("#bankCardNumberProveDataList");
                    var certificateScanning = Common.fileRequire("#certificateScanningDataList");

                    if(isEmpty){
                        Common.alert("银行卡材料信息附件必须上传");
                    }else if(certificateScanning){
                        Common.alert("相应的证书扫描件附件必须上传");
                    }else {
                        Common.openConfirm("确认申报?", function () {
                        skillApi.savedeclaration($('#addForm'), function () {
                            parent.window.dataReload();
                            Common.info("保存并申报成功");
                            Lib.closeFrame();
                        });
                    }, null);
                }
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }
    			
    }
    exports('add',view);
});